package com.example.datahub;

import com.aliyun.datahub.client.DatahubClient;
import com.aliyun.datahub.client.DatahubClientBuilder;
import com.aliyun.datahub.client.auth.Account;
import com.aliyun.datahub.client.auth.AliyunAccount;
import com.aliyun.datahub.client.common.DatahubConfig;
import com.aliyun.datahub.client.model.ListSubscriptionResult;
import com.aliyun.datahub.client.model.SubscriptionEntry;

public class SDKTest {

    private static String accessKey = null;
    private static String accessId = null;
    private static String endpoint = null;
    private static String projectName;
    private static String topicName;

    public static void main(String[] args) {
        Account account = new AliyunAccount(accessId, accessKey);
        DatahubClient client = DatahubClientBuilder.newBuilder().setDatahubConfig(new DatahubConfig(endpoint, account)).build();
        ListSubscriptionResult listSubscriptionResult = client.listSubscription(projectName, topicName, 1, 50);
        if (listSubscriptionResult.getSubscriptions().size() > 0) {
            System.out.println(listSubscriptionResult.getTotalCount());
            System.out.println(listSubscriptionResult.getSubscriptions().size());
            for (SubscriptionEntry entry : listSubscriptionResult.getSubscriptions()) {
                System.out.println(entry.getSubId() + "\t"
                        + entry.getState() + "\t"
                        + entry.getType() + "\t"
                        + entry.getComment());
            }
        }
    }
}
